package dao.majorunit;

import java.util.List;

import util.paramvo.SearchParamVO;
import vo.MajorunitVO;

import com.ibatis.sqlmap.client.SqlMapClient;

public class MajorunitDAOImpl implements MajorunitDAO{
	private SqlMapClient sqlMapClient;

	public void setSqlMapClient(SqlMapClient sqlMapClient) {
		this.sqlMapClient = sqlMapClient;
	}

	@Override
	public List<MajorunitVO> getSearchedUnitByWord(SearchParamVO search) throws Exception {
		return sqlMapClient.queryForList("majorunit.getSearchedUnitByWord", search);
	}

	@Override
	public int countSearchedUnitByWord(List<String> search) throws Exception {
		return (Integer) sqlMapClient.queryForObject("majorunit.countSearchedUnitByWord", search);
	}

	@Override
	public MajorunitVO getOneUnit(int majorunit_no) throws Exception {
		return (MajorunitVO) sqlMapClient.queryForObject("majorunit.getOneUnit", majorunit_no);
	}

	@Override
	public void registerMajorunit(MajorunitVO param) throws Exception {
		sqlMapClient.insert("majorunit.registerMajorunit", param);
	}

	@Override
	public void updateMajorunit(MajorunitVO param) throws Exception {
		sqlMapClient.update("majorunit.updateMajorunit", param);
	}

	@Override
	public void deleteMajorunit(int majorunit_no) throws Exception {
		sqlMapClient.update("majorunit.deleteMajorunit", majorunit_no);
	}

	@Override
	public List<MajorunitVO> getMajorunits(int univ_no) throws Exception {
		return sqlMapClient.queryForList("majorunit.getMajorunits", univ_no);
	}

	@Override
	public void deleteMajorunitInUniv(int univ_no) throws Exception {
		sqlMapClient.update("majorunit.deleteMajorunitInUniv", univ_no);
	}
}
